﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>综合信息管理平台</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/Base/lndex.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="/JqueryPlug/layer/layer/layer.js"></script>
    <script src="/Scripts/avalon.min.js"></script>
    <script src="/Scripts/SZHLCommon.js"></script>
    <style>
    </style>
    <script>
        var model = avalon.define({
            $id: "Index",
            UserName: ComFunJS.getQueryString("UserName") ? ComFunJS.getQueryString("UserName") : "admin",
            MenuData: [],
            ChiMenuData: [],
            SelPmenu: "36",
            Selmenu: "",
            GETMENU: function (pid) {
                $.getJSON('/API/SZHLAPI.ashx?Action=GETMENU', { "P1": pid, "UserName": model.UserName }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.ChiMenuData = resultData.Result;
                        model.SelPmenu = pid;
                    }
                })
            },
            addTab: function (url, menuid, title) {

                model.Selmenu = menuid;

                //如果已经存在该Tab，则转到该Tab
                if ($("#Tab" + menuid).length > 0) {
                    $("a[href='#Tab" + menuid + "']").parent().trigger('click');
                }
                else {
                    $(".menutab li a").removeClass("selected");
                    $(".tabContent").hide();
                    var tabli = $('<li><a href="#Tab' + menuid + '" class="selected">' + title + '<img class="deltab" src="../images/close.png" style="width:16px; height:16px;vertical-align:middle; margin-left:5px;visibility:hidden;"></a></li>');
                    tabli.find(".deltab").click(function () {
                        tabli.remove();
                        $("#Tab" + menuid).remove();
                        if ($(".tabiframe:visible").length === 0) {
                            $($(".menutab li").last().find('a').addClass("selected").attr("href")).show();
                        }
                    })
                    tabli.bind('click', function () {
                        $(".tabContent").hide();
                        $($(this).find('a').attr("href")).show();
                        $(".menutab li a").removeClass("selected");
                        $(this).find('a').addClass("selected");
                    })
                    tabli.hover(function () {
                        $(this).find(".deltab").css({ visibility: 'visible' });
                    },
                    function () {
                        $(this).find(".deltab").css({ visibility: 'hidden' });
                    })
                    $(".menutab").append(tabli);
                    var nframe = $("#tab1").find('iframe').clone();
                    nframe.attr("id", "frame" + menuid).attr("name", "frame" + menuid).attr("src", url);
                    var newcontent = $('<div id="Tab' + menuid + '" class="tabContent"></div>').append(nframe);
                    $("#dvContent").append(newcontent);
                    SetFrameHeight("frame" + menuid);

                    //总Tab数不能超过5个,如果超过了,则自动删除最早打开的
                    if ($(".menutab li").length > 5) {
                        $(".menutab li").eq(1).remove();
                        $(".tabContent").eq(1).remove();
                    }
                }
            },
            SetFrameHeight: function (framename) {
                var oFrm = document.getElementById(framename);
                oFrm.onload = oFrm.onreadystatechange = function () {
                    if (this.readyState && this.readyState != 'complete') return;
                    else {
                        var mainheight = $("#dvContent").height() - 45;
                        $("#" + framename).height(mainheight);
                        $("#mastmenu").height(mainheight);
                        $(window.frames[framename].document).find(".maindiv").css({ height: mainheight + "px", overflow: "auto" });
                    }
                }
            }
        });
        avalon.ready(function () {
            //获取主要菜单
            $.getJSON('/API/SZHLAPI.ashx?Action=GETPMENU', { "P1": "", "UserName": model.UserName }, function (resultData) {
                model.MenuData = resultData.Result;
                model.GETMENU(model.SelPmenu)
            })
        })
    </script>

</head>

<body ms-controller="Index">
    <div id="topdv" style="z-index: 50; position: absolute; left: 0px; right: 0; height: 88px; background-image: url(images/Index/top_bg.png)" class="colorBg3">

        <ul class="nav" style="position: absolute; left:280px">
            <li ms-repeat-item="MenuData" ms-attr-id="item.AuthCode" ms-click="GETMENU(item.AuthCode)" >
                <a href="#" ms-class="selected:item.AuthCode==SelPmenu" style="padding:0">
                    <img ms-src="item.Ico"><h2 style="margin:0">{{item.AuthName}}</h2>
                </a>
            </li>
        </ul>

        <div class="topright" style="position: absolute; right: 0px; font-size: 16px">
            <ul>
                <li>
                    <span>
                        <img src="/images/Index/help.png" title="帮助" class="helpimg" />
                    </span>
                </li>
                <li><a href="login.html" target="_parent">退出</a></li>
            </ul>

            <div class="user" style="cursor: pointer">
                <span></span>

            </div>

        </div>
    </div>


    <div style="clear: right; width: 167px; position: absolute; top: 88px;" id="leftdv">

        <dl class="leftmenu" id="mastmenu">
            <dd>
                <div ms-repeat-item="ChiMenuData">
                    <div class="title"><span><img src="/images/Index/leftico01.png"></span>{{item.AuthName}}</div>
                    <ul class="menuson">
                        <li ms-repeat-el="item.ChiMenu" ms-class="active:el.AuthCode==Selmenu" ms-click="addTab(el.FileName,el.AuthCode,el.AuthName)"><a href="#">{{el.AuthName}}</a></li>

                    </ul>
                </div>
            </dd>

        </dl>

    </div>
    <div style="position: absolute; top: 88px; right: 0px; left:167px; bottom: 0px;" id="dvContent">
        <div class="place">

            <ul class="menutab">
                <li>
                    <a href="#tab1" class="selected">
                        <img src="/images/Index/ico01.png" style="width: 26px; height: 26px; vertical-align: middle; margin-right: 5px">首页
                    </a>
                </li>
            </ul>
            <div style="padding-top: 8px; float: right; padding-right: 8px;">
                <img src="/images/Index/sync.png" style="cursor: pointer; margin-right: 10px" title="刷新当前页面" id="btsximg">

                <img src="/images/Index/t05.png" border="1" style="cursor: pointer; margin-right: 10px" title="个人设置" id="imgSet">
            </div>
        </div>

        <div id="tab1" class="tabContent">
            <iframe marginwidth="0" class="tabiframe" marginheight="0" frameborder="0" scrolling="no" height="100%" id="main" name="main" width="100%" src="/View/Base/CommonList.html"></iframe>
        </div>

    </div>
    <script type="text/javascript">
        model.SetFrameHeight('main')
    </script>
    <input id="hidUserName" type="hidden" value="" />
</body>
</html>
